package com.hp.snap.gr.action.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.hp.snap.gr.exception.ActionException;
import com.hp.snap.gr.model.jaxb.ActionType;
import com.hp.snap.gr.model.jaxb.GeneralActionType;
import com.hp.snap.gr.model.jaxb.ParameterType;
import com.hp.snap.gr.utils.GRStatusHelper;
import com.hp.snap.gr.utils.Utils;
import com.hp.snap.gr.model.GRStatus;

public class SetSGMStatusActionHandler extends AbstractActionHandler {

    private static Logger logger = LoggerFactory.getLogger(SetSGMStatusActionHandler.class);
    
    @Override
    public void execute(ActionType action, Map<String, Object> actionPlanInputs, Map<String, Object> actionPlanOutputs)
            throws ActionException {
        GeneralActionType actionType = (GeneralActionType) action;
        List<ParameterType> parameterTypes = actionType.getParameter();
        Map<String, String> parameterMap = Utils.contructParamMap(parameterTypes);
        String status = parameterMap.get("Status") ;
        if(logger.isDebugEnabled()){
            logger.debug("Set the Site status is {}",status);
        }
        GRStatusHelper.updateStatus(GRStatus.valueOf(status));
    }

}
